﻿Imports System.Data.OleDb
Imports System.Data
Imports System.Xml
Imports System.Xml.Linq


Public Class RssFeed
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim conn As OleDbConnection
        Dim app_path As String
        Dim xmltxtwtr As XmlTextWriter
        Dim cmd As OleDbCommand
        Dim datareader As OleDbDataReader
        app_path = System.AppDomain.CurrentDomain.BaseDirectory()
        conn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & app_path & "\\App_Data\\JDFan.accdb;Persist Security Info=True")

        xmltxtwtr = New XmlTextWriter(Response.OutputStream, Encoding.UTF8)
        xmltxtwtr.WriteStartDocument()
        xmltxtwtr.WriteStartElement("rss")
        xmltxtwtr.WriteAttributeString("version", "2.0")
        xmltxtwtr.WriteStartElement("channel")
        xmltxtwtr.WriteElementString("title", "Rss Feed Johnny Depp Fan Club")
        conn.Open()

        cmd = New OleDbCommand("select * from JDF_List", conn)
        datareader = cmd.ExecuteReader()
        While datareader.Read()
            xmltxtwtr.WriteStartElement("item")
            xmltxtwtr.WriteElementString("title", datareader("Movie_Name").ToString())
            xmltxtwtr.WriteElementString("rating", datareader("Rating").ToString())
            xmltxtwtr.WriteElementString("director", datareader("Director_Name").ToString())
            xmltxtwtr.WriteElementString("roleofJD", datareader("Role_of_JD").ToString())
            xmltxtwtr.WriteElementString("description", datareader("Description").ToString())
            xmltxtwtr.WriteElementString("moviecategory", datareader("Movie_Category").ToString())
            xmltxtwtr.WriteElementString("moviebusiness", datareader("Movie_Business").ToString())
            xmltxtwtr.WriteEndElement()
        End While
        xmltxtwtr.WriteEndElement()
        xmltxtwtr.WriteEndElement()
        xmltxtwtr.WriteEndDocument()
        xmltxtwtr.Flush()
        xmltxtwtr.Close()
        conn.Close()
        Response.End()

    End Sub
End Class
